/**
 * 租户API
 *
 * @Date 2021/3/20 16:23
 * @author 周世焕
 */


import axios from '@/libs/api.request'
import qs from 'qs'

/**
 * 获取租户信息（根据site查询）
 */
export function getTenantBySite(site) {
    return  axios.request({
        url: '/v1/auth/tenant/site',
        params:{site},
        method: 'get'
    })
}

/**
 * 获取租户信息（根据site查询）
 */
export function getTenantById(tenantId) {
    return  axios.request({
        url: '/v1/auth/tenant',
        params:{tenantId},
        method: 'get'
    })
}

/**
 * 加入租户
 */
export function joinTenant(data) {
    return  axios.request({
        url: '/v1/auth/tenant/join',
        data:data,
        method: 'post'
    })
}


/**
 * 创建租户
 */
export function saveTenant(data) {
    return  axios.request({
        url: '/v1/auth/tenant',
        data:data,
        method: 'post'
    })
}

/**
 * 查询员工列表
 */
export function findPeopleList(deptId,username) {
    return  axios.request({
        url: '/v1/auth/tenant/people/list',
        params:{deptId,username},
        method: 'get'
    })
}

/**
 * 查询员工列表(根据名字搜索)
 */
export function findPeopleByName(name) {
    return  axios.request({
        url: '/v1/auth/tenant/people/name',
        params: {name},
        method: 'get'
    })
}

/**
 * 更改员工信息
 */
export function updatePeople(data) {
    return  axios.request({
        url: '/v1/auth/tenant/people',
        data: data,
        method: 'put'
    })
}

/**
 * 批量删除员工
 */
export function deletePeopleBatch(userIds) {
    return  axios.request({
        url: '/v1/auth/tenant/people/batch',
        params: {userIds:userIds},
        method: 'delete',
        paramsSerializer: params => {
            return qs.stringify(params, { indices: false })
        }
    })
}

/**
 * 查询加入申请列表
 * @returns {*}
 */
export function findJoinRequestList() {
    return  axios.request({
        url: '/v1/auth/tenant/join/list',
        method: 'get'
    })
}

/**
 * 同意加入请求
 * @param userIds
 * @returns {*}
 */
export function joinConfirmBatch(userIds) {
    return  axios.request({
        url: '/v1/auth/tenant/join/confirm/batch',
        params: {userIds:userIds},
        method: 'post',
        paramsSerializer: params => {
            return qs.stringify(params, { indices: false })
        }
    })
}

/**
 * 拒绝加入请求
 * @param userIds
 * @returns {*}
 */
export function joinDenyBatch(userIds) {
    return  axios.request({
        url: '/v1/auth/tenant/join/deny/batch',
        params: {userIds:userIds},
        method: 'post',
        paramsSerializer: params => {
            return qs.stringify(params, { indices: false })
        }
    })
}
